//
//  ViewController.m
//  定位跟踪
//
//  Created by Bc_Ltf on 15/1/14.
//  Copyright (c) 2015年 Bc_Ltf. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<MKMapViewDelegate>

@end

@implementation ViewController
@synthesize mapView;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self initAll];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*--------------------------------初始化函数----------------------------------*/
-(void)initAll
{
    self.locationManage=[CLLocationManager new];
    [self.locationManage requestAlwaysAuthorization];
    
    if([CLLocationManager locationServicesEnabled])
    {
        mapView.mapType=MKMapTypeStandard;
        mapView.delegate=self;
        mapView.showsUserLocation=YES;
        [mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
    }
    
    
        MKCoordinateRegion viewRegion=MKCoordinateRegionMakeWithDistance(mapView.centerCoordinate, 1000, 1000);
    
        // animate：又生气的，激活
        // 设置重新显示区域
        [mapView setRegion:viewRegion animated:YES];
    NSLog(@"%i and %i",(int)mapView.centerCoordinate.latitude,(int)mapView.centerCoordinate.longitude);
    
    
}

/*--------------------------------实现mapview代理方法----------------------------------*/
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    
    mapView.centerCoordinate=userLocation.location.coordinate;
    NSLog(@"%i and %i",(int)mapView.centerCoordinate.latitude,(int)mapView.centerCoordinate.longitude);//    MKCoordinateRegion viewRegion=MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 1000, 1000);
//    
//    // animate：又生气的，激活
//    // 设置重新显示区域
//    [mapView setRegion:viewRegion animated:YES];

    //调整地图比例 region:地区范围部位

}



@end
